package com.hzlx.dao.impl;

import com.hzlx.dao.BaseDao;
import com.hzlx.dao.TOrderDetailInfoDao;
import com.hzlx.entity.TOrderDetailInfo;

import java.util.List;

/**
 * @author 86166
 * @version 1.0
 * @description: TODO
 * @date 2023/4/9 22:35
 */
public class TOrderDetailInfoDaoImpl extends BaseDao<TOrderDetailInfo> implements TOrderDetailInfoDao {
    @Override
    public int deleteByPrimaryKey(Integer id) {
        String sql = "delete * from t_detail_info where id=?";
        return executeUpdate(sql, id);
    }

    @Override
    public int insert(TOrderDetailInfo record) {
        String sql = "insert into t_detail_info values(?,?,?,?,?)";
        return  executeUpdate(sql,null,record.getOrderNo(),record.getFoodId(),record.getCountNum(),record.getTotalMoney());
    }

    @Override
    public int insertSelective(TOrderDetailInfo record) {
        return 0;
    }

    @Override
    public TOrderDetailInfo selectByPrimaryKey(Integer id) {
        String sql = "select * from t_order_detail_info where id = ?";
        List<TOrderDetailInfo> tOrderDetailInfos = executeQuery(sql, com.hzlx.entity.TFoodInfo.class, id);
        TOrderDetailInfo tOrderDetailInfo = null;
        if (tOrderDetailInfos.size()>0) {
            for (TOrderDetailInfo orderDetailInfo : tOrderDetailInfos) {
                tOrderDetailInfo = orderDetailInfo;
            }
        }

        return tOrderDetailInfo;
    }

    @Override
    public int updateByPrimaryKeySelective(TOrderDetailInfo record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(TOrderDetailInfo record) {
        String sql = "update t_order_detail_info set business_id=?, name=?,price=?,ment=?,status=? where id=?";
        return executeUpdate(sql,null,record.getOrderNo(),record.getFoodId(),record.getCountNum(),record.getTotalMoney());
    }
}
